﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Reflection;

namespace BindToolkit.DataAnnotations
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=true)]
    public class FormatErrorAttribute:Attribute
    {
        public FormatErrorAttribute()
            : base()
        {
        }
        public string ErrorMessage { set; get; }
        public string ErrorMessageResourceName { get; set; }
        public Type ErrorMessageResourceType { get; set; }
        public string GetErrorMessage()
        {
            if (ErrorMessageResourceType != null && ErrorMessageResourceName!= null)
            {
                PropertyInfo pi=ErrorMessageResourceType.GetProperty(ErrorMessageResourceName, BindingFlags.Static|BindingFlags.Public);
                return pi.GetValue(null, null).ToString();
            }
            else return ErrorMessage;
        }
    }
}
